int[] f={0,0,0,8,1,0,0,0,6,0,9,0,0,2,0,5,6,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,2,0,1,0,0,1,0,0,7,0,0,0,2,0,7,8,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,2,0,4,0,9,0,0,0};
size(10cm);
int N = 9;
path cell = box((0,0),(1,1));
int block=0;
real pastell=4;
real r;
real g;
real b;
r=(1/pastell+1)*(pastell+sin(2*pi*0/9));
g=(1/pastell+1)*(pastell+sin(2*pi/3+2*pi*0/9));
b=(1/pastell+1)*(pastell+sin(4*pi/3+2*pi*0/9));
fill(shift(floor((21-1)/9), (21-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((30-1)/9), (30-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((31-1)/9), (31-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((39-1)/9), (39-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((40-1)/9), (40-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((48-1)/9), (48-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((49-1)/9), (49-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((57-1)/9), (57-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((66-1)/9), (66-1)%9)*cell, rgb(r,g,b));
r=(1/pastell+1)*(pastell+sin(2*pi*1/9));
g=(1/pastell+1)*(pastell+sin(2*pi/3+2*pi*1/9));
b=(1/pastell+1)*(pastell+sin(4*pi/3+2*pi*1/9));
fill(shift(floor((1-1)/9), (1-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((10-1)/9), (10-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((19-1)/9), (19-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((28-1)/9), (28-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((29-1)/9), (29-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((38-1)/9), (38-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((47-1)/9), (47-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((56-1)/9), (56-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((65-1)/9), (65-1)%9)*cell, rgb(r,g,b));
r=(1/pastell+1)*(pastell+sin(2*pi*2/9));
g=(1/pastell+1)*(pastell+sin(2*pi/3+2*pi*2/9));
b=(1/pastell+1)*(pastell+sin(4*pi/3+2*pi*2/9));
fill(shift(floor((26-1)/9), (26-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((35-1)/9), (35-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((44-1)/9), (44-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((53-1)/9), (53-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((61-1)/9), (61-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((62-1)/9), (62-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((71-1)/9), (71-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((80-1)/9), (80-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((81-1)/9), (81-1)%9)*cell, rgb(r,g,b));
r=(1/pastell+1)*(pastell+sin(2*pi*3/9));
g=(1/pastell+1)*(pastell+sin(2*pi/3+2*pi*3/9));
b=(1/pastell+1)*(pastell+sin(4*pi/3+2*pi*3/9));
fill(shift(floor((58-1)/9), (58-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((59-1)/9), (59-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((60-1)/9), (60-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((68-1)/9), (68-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((69-1)/9), (69-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((70-1)/9), (70-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((77-1)/9), (77-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((78-1)/9), (78-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((79-1)/9), (79-1)%9)*cell, rgb(r,g,b));
r=(1/pastell+1)*(pastell+sin(2*pi*4/9));
g=(1/pastell+1)*(pastell+sin(2*pi/3+2*pi*4/9));
b=(1/pastell+1)*(pastell+sin(4*pi/3+2*pi*4/9));
fill(shift(floor((37-1)/9), (37-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((46-1)/9), (46-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((55-1)/9), (55-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((64-1)/9), (64-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((67-1)/9), (67-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((73-1)/9), (73-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((74-1)/9), (74-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((75-1)/9), (75-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((76-1)/9), (76-1)%9)*cell, rgb(r,g,b));
r=(1/pastell+1)*(pastell+sin(2*pi*5/9));
g=(1/pastell+1)*(pastell+sin(2*pi/3+2*pi*5/9));
b=(1/pastell+1)*(pastell+sin(4*pi/3+2*pi*5/9));
fill(shift(floor((2-1)/9), (2-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((3-1)/9), (3-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((4-1)/9), (4-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((5-1)/9), (5-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((6-1)/9), (6-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((7-1)/9), (7-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((11-1)/9), (11-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((12-1)/9), (12-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((20-1)/9), (20-1)%9)*cell, rgb(r,g,b));
r=(1/pastell+1)*(pastell+sin(2*pi*6/9));
g=(1/pastell+1)*(pastell+sin(2*pi/3+2*pi*6/9));
b=(1/pastell+1)*(pastell+sin(4*pi/3+2*pi*6/9));
fill(shift(floor((8-1)/9), (8-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((9-1)/9), (9-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((18-1)/9), (18-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((27-1)/9), (27-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((36-1)/9), (36-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((45-1)/9), (45-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((54-1)/9), (54-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((63-1)/9), (63-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((72-1)/9), (72-1)%9)*cell, rgb(r,g,b));
r=(1/pastell+1)*(pastell+sin(2*pi*7/9));
g=(1/pastell+1)*(pastell+sin(2*pi/3+2*pi*7/9));
b=(1/pastell+1)*(pastell+sin(4*pi/3+2*pi*7/9));
fill(shift(floor((13-1)/9), (13-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((14-1)/9), (14-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((15-1)/9), (15-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((16-1)/9), (16-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((17-1)/9), (17-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((22-1)/9), (22-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((23-1)/9), (23-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((25-1)/9), (25-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((34-1)/9), (34-1)%9)*cell, rgb(r,g,b));
r=(1/pastell+1)*(pastell+sin(2*pi*8/9));
g=(1/pastell+1)*(pastell+sin(2*pi/3+2*pi*8/9));
b=(1/pastell+1)*(pastell+sin(4*pi/3+2*pi*8/9));
fill(shift(floor((24-1)/9), (24-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((32-1)/9), (32-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((33-1)/9), (33-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((41-1)/9), (41-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((42-1)/9), (42-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((43-1)/9), (43-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((50-1)/9), (50-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((51-1)/9), (51-1)%9)*cell, rgb(r,g,b));
fill(shift(floor((52-1)/9), (52-1)%9)*cell, rgb(r,g,b));
draw((0,0) -- (N,0), black+linewidth(3pt));
draw((N,0) -- (N,N), black+linewidth(3pt));
draw((N,N) -- (0,N), black+linewidth(3pt));
draw((0,N) -- (0,0), black+linewidth(3pt));
real[] B={5.000000e-01,1.000000e+00, 1.000000e+00,3.500000e+00, 1.000000e+00,4.500000e+00, 1.000000e+00,5.500000e+00, 5.000000e-01,7.000000e+00, 1.000000e+00,6.500000e+00, 1.000000e+00,7.500000e+00, 1.500000e+00,1.000000e+00, 1.500000e+00,3.000000e+00, 2.000000e+00,2.500000e+00, 2.000000e+00,5.500000e+00, 1.500000e+00,8.000000e+00, 2.000000e+00,7.500000e+00, 2.500000e+00,1.000000e+00, 2.500000e+00,2.000000e+00, 3.000000e+00,1.500000e+00, 2.500000e+00,3.000000e+00, 3.000000e+00,3.500000e+00, 2.500000e+00,5.000000e+00, 3.000000e+00,4.500000e+00, 2.500000e+00,6.000000e+00, 2.500000e+00,7.000000e+00, 2.500000e+00,8.000000e+00, 4.000000e+00,5.000000e-01, 3.500000e+00,2.000000e+00, 3.500000e+00,4.000000e+00, 3.500000e+00,6.000000e+00, 3.500000e+00,7.000000e+00, 4.000000e+00,6.500000e+00, 3.500000e+00,8.000000e+00, 4.500000e+00,1.000000e+00, 4.500000e+00,2.000000e+00, 4.500000e+00,4.000000e+00, 4.500000e+00,7.000000e+00, 4.500000e+00,8.000000e+00, 5.500000e+00,1.000000e+00, 5.500000e+00,2.000000e+00, 5.500000e+00,4.000000e+00, 6.000000e+00,3.500000e+00, 6.000000e+00,4.500000e+00, 6.000000e+00,5.500000e+00, 5.500000e+00,7.000000e+00, 6.000000e+00,6.500000e+00, 5.500000e+00,8.000000e+00, 6.500000e+00,1.000000e+00, 6.500000e+00,2.000000e+00, 6.500000e+00,3.000000e+00, 7.000000e+00,3.500000e+00, 6.500000e+00,6.000000e+00, 7.000000e+00,6.500000e+00, 6.500000e+00,8.000000e+00, 7.500000e+00,1.000000e+00, 7.500000e+00,2.000000e+00, 8.000000e+00,1.500000e+00, 7.500000e+00,3.000000e+00, 8.000000e+00,2.500000e+00, 7.500000e+00,4.000000e+00, 7.500000e+00,7.000000e+00, 7.500000e+00,8.000000e+00, 8.000000e+00,8.500000e+00, 8.500000e+00,4.000000e+00, 8.500000e+00,7.000000e+00, };
int k=0;
for (int i = 0; i < N; ++i) {
	for (int j = 0; j < N; ++j) {
		draw(shift(i, j)*cell, black+linewidth(0.5pt));
		if (f[k]>0)
			label(string(f[k]),p = fontsize(20pt), (i+0.5,j+0.5));
		k=k+1;
	}
}
real x;
real y;
for (int i = 0; i < B.length/2; ++i) {
	x=B[2*i];
	y=B[2*i+1];
	if (x-floor(x)>0.1)
		draw((floor(x),y) -- (floor(x)+1,y), black+linewidth(2pt));
	else
		draw((x, floor(y)) -- (x, floor(y)+1), black+linewidth(2pt));
}
